package rensoft.gwt.client.platform.json;

import cs.java.json.JSONBoolean;
import cs.java.json.JSONTypeImpl;
import cs.java.json.JSONValue;

public class JSONBooleanImpl extends JSONTypeImpl implements JSONBoolean {

  private static JSONBooleanImpl TRUE = new JSONBooleanImpl(com.google.gwt.json.client.JSONBoolean
      .getInstance(true));
  private static JSONBooleanImpl FALSE = new JSONBooleanImpl(com.google.gwt.json.client.JSONBoolean
      .getInstance(false));

  public static JSONBoolean getInstance(boolean value) {
    if (value) return TRUE;
    return FALSE;
  }

  private final com.google.gwt.json.client.JSONBoolean value;

  JSONBooleanImpl(com.google.gwt.json.client.JSONBoolean value) {
    super(value);
    this.value = value;
  }

  @Override
  public JSONBoolean asJSONBoolean() {
    return this;
  }

  @Override
  public JSONValue<Boolean> asValue() {
    return this;
  }

  public Boolean get() {
    return value.booleanValue();
  }
}
